#include<stack>
#include<iostream>
using namespace std;
//栈是先进后出不允许被遍历的，想要查看得让栈顶的元素依次出栈
void test01() {
    stack<int> s;
    s.push(1);
    s.push(2);
    s.push(3);
    s.push(4);
    //查看栈
    cout<<"查看前:"<<s.size()<<endl;

    while (!s.empty()) {
        cout << s.top() << " ";
        s.pop();//删除栈顶
    }
    cout << endl;
    cout<<"查看后的大小: "<<s.size()<<endl;
}
int main() {
    test01();
    return 0;
}